package com.c.yinyuezhushou.Dialog;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.c.yinyuezhushou.Adapter.SongListAdapter1;
import com.c.yinyuezhushou.Interface.MyInterface;
import com.c.yinyuezhushou.MRetrofit.MusicItem;
import com.c.yinyuezhushou.MyApplication;
import com.c.yinyuezhushou.R;

public class SongListHoemDialog extends AlertDialog {
    private Boolean cancelable;
    private MyApplication myApplication;
    private RecyclerView recyclerView;
    private MusicItem musicItem;
    protected SongListHoemDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener, MyApplication myApplication, MusicItem musicItem) {
        super(context, cancelable, cancelListener);
        this.cancelable = cancelable;
        this.myApplication = myApplication;
        this.musicItem = musicItem;
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_home_song_list);
        setCancelable(cancelable);
        Window window = getWindow();
        window.setBackgroundDrawableResource(R.color.touming);
        WindowManager.LayoutParams params = window.getAttributes();

        params.gravity = Gravity.CENTER;

        window.setAttributes(params);

        recyclerView = findViewById(R.id.dhsl_rec1);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(linearLayoutManager);

        recyclerView.setAdapter(new SongListAdapter1(myApplication.getMyDButil().getSongList(), myApplication, musicItem, new MyInterface() {
            @Override
            public void con() {
                SongListHoemDialog.this.dismiss();
            }

            @Override
            public void can() {

            }

            @Override
            public void musicItem(MusicItem musicItem) {

            }
        }));
    }
}
